﻿SET QUOTED_IDENTIFIER ON
GO
SET ARITHABORT ON
GO
SET NUMERIC_ROUNDABORT OFF
GO
SET CONCAT_NULL_YIELDS_NULL ON
GO
SET ANSI_NULLS ON
GO
SET ANSI_PADDING ON
GO
SET ANSI_WARNINGS ON
GO

-- =============================================
-- Author:		Adrian Kaczmarek
-- Create date: 2013-08-12
-- =============================================
CREATE PROCEDURE [dbo].[bhp_NemoGroupSave] (
	@GroupId					INT,
	@DisplayName			NVARCHAR(400),
	@Identyficator				NVARCHAR(1000),
	@SupportTranslate		BIT,
	@ReadOnly					BIT
)
WITH ENCRYPTION
AS
BEGIN

	IF NOT EXISTS (SELECT 1 FROM bht_Groups WHERE Id = @GroupId)
		INSERT INTO bht_Groups (Id, Name, Identyficator, EnableTranslate, [ReadOnly]) VALUES (@GroupId, @DisplayName, @Identyficator, @SupportTranslate, @ReadOnly)
	ELSE
		UPDATE
			bht_Groups
		SET
			Name = @DisplayName,
			Identyficator = @Identyficator,
			EnableTranslate = @SupportTranslate,
			[ReadOnly] = @ReadOnly
		WHERE
			Id = @GroupId
	
	UPDATE
		n_Tree
	SET
		mtime = GETDATE(),
		muser = 9999999
	WHERE
		id = @GroupId

END
